package org.dothwinds.springbootstudy.controller;

import org.dothwinds.springbootstudy.dao.UserRepository;
import org.dothwinds.springbootstudy.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserRepository userRepository;

    @GetMapping(value = "/addUser")
    public String addUser(@RequestParam(value = "name") String name){
        User user = new User();
        user.setName(name);
        user.setAddr("测试地址");
        user.setCompany("测试公司");
        userRepository.save(user);
        return "insert success";
    }
}
